#include <QtCore/QCoreApplication>
#include <QScopedPointer>
#include "tplconfig.h"
#include "tplbinaryexpression.h"
#include "tplgetexpression.h"

void myMessageOutput(QtMsgType type, const char *msg) {
    switch (type) {
    case QtDebugMsg:
        if(!TplConfig::getConfig()->noDebug())
            fprintf(stdout, "Debug: %s\n", msg);
        break;
    case QtWarningMsg:
        if(!TplConfig::getConfig()->noWarn())
            fprintf(stderr, "Warning: %s\n", msg);
        break;
    case QtCriticalMsg:
        if(!TplConfig::getConfig()->noErr())
            fprintf(stderr, "Critical: %s\n", msg);
        break;
    case QtFatalMsg:
        if(!TplConfig::getConfig()->noErr())
            fprintf(stderr, "Fatal: %s\n", msg);
        QCoreApplication::quit();
    }
}

int main(int argc, char *argv[]) {

    TplConfig::getConfig();
    qInstallMsgHandler(myMessageOutput);
    QCoreApplication a(argc, argv);

    TplConfig::getConfig()->parseCommandLine(argc, argv);

    return a.exec();
}
